package com.jh.user.pojo.freeQuick;

import java.util.Objects;

import static com.google.common.base.Strings.isNullOrEmpty;

public enum  CardType {
    /**
     * 借记卡（储蓄卡）
     */
    DEBIT(0, "DEBIT", "\u501f\u8bb0\u5361\uff08\u50a8\u84c4\u5361\uff09"),

    /**
     * 信用卡
     */
    CREDIT(1, "CREDIT", "\u4fe1\u7528\u5361"),

    ;

    private final int code;
    private final String desc;
    private final String value;

    CardType(int code, String desc, String value) {
        this.code = code;
        this.desc = desc;
        this.value = value;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public String getValue() {
        return value;
    }


    public static CardType of(String value) {
        if (isNullOrEmpty(value)) {
            return null;
        }
        for (CardType scc: values()) {
            if (Objects.equals(scc.getValue(), value)) {
                return scc;
            }
        }
        return null;
    }

    public static CardType code(String value) {
        if (isNullOrEmpty(value)) {
            return null;
        }
        for (CardType scc: values()) {
            if (Objects.equals(scc.getCode(), value)) {
                return scc;
            }
        }
        return null;
    }
}
